package FactoryMethod.cashier;

/**
 * @author duanzhizhou
 * @date 2024/9/25
 */
public class RebateCashier extends CashDecorator {
    
    private final double discount;
    
    public RebateCashier(Cashier cashier, double discount) {
        super(cashier);
        this.discount = discount;
    }
    
    @Override
    public double check(double price, int cnt) {
        double total = super.check(price, cnt);
        return total != 0 ? total * discount : price * cnt * discount;
    }
}
